package com.common.exception;

import com.common.base.BaseEnum;

/**
* @version: V1.0
* @author: szw
* @className: BaseException
* @packageName: BaseException
* @description: 基础异常类，抛异常使用后续分多个业务需继承该类
* @data: 2021-1-19 
**/  
public class BaseException extends RuntimeException {

   //异常信息
    private String errorMsg;
    //错误码
    private String code;

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public BaseException(String message) {
        super(message);
        this.errorMsg = message;
    }

    public BaseException(BaseEnum baseEnum) {
        this.code = baseEnum.getCode();
        this.errorMsg = baseEnum.getDesc();
    }

    public BaseException(BaseEnum baseEnum, Throwable cause) {
        super(baseEnum.getDesc(), cause);
        this.code = baseEnum.getCode();
        this.errorMsg = baseEnum.getDesc();
    }

    public BaseException(Throwable cause) {
        super(cause);
        this.code = BaseEnum.SERVICE_ERROR.getCode();
        this.errorMsg = BaseEnum.SERVICE_ERROR.getDesc();
    }


    @Override
    public String getMessage() {
        return super.getMessage();
    }

}
